package popcorn.ticket.tool;

import java.util.List;

/**
 * 根据前端需要的格式进行了适当的调整
 *
 * @param <T>
 */
public class PageData<T> {

	private List<T> data;// 存储的分页的数据 ,等价于我们刚刚查询的list
	private int page;// 当前页
	private int count;// 总记录数
	private int limit;// 每页的记录数   
	private int code;
	private String msg;
	
	public PageData() {
		super();
	}
	/**
	 * 带参构造
	 * @param data  list集合
	 * @param page	当前页
	 * @param count	总记录数
	 * @param limit 每页数据
	 */
	public PageData(List<T> data, int page, int count, int limit) {
		super();
		this.data = data;
		this.page = page;
		this.count = count;
		this.limit = limit;

	}
	/**
	 * @return the data
	 */
	public List<T> getData() {
		return data;
	}
	/**
	 * @param data the data to set
	 */
	public void setData(List<T> data) {
		this.data = data;
	}
	/**
	 * @return the page
	 */
	public int getPage() {
		return page;
	}
	/**
	 * @param page the page to set
	 */
	public void setPage(int page) {
		this.page = page;
	}
	/**
	 * @return the count
	 */
	public int getCount() {
		return count;
	}
	/**
	 * @param count the count to set
	 */
	public void setCount(int count) {
		this.count = count;
	}
	/**
	 * @return the limit
	 */
	public int getLimit() {
		return limit;
	}
	/**
	 * @param limit the limit to set
	 */
	public void setLimit(int limit) {
		this.limit = limit;
	}
	/**
	 * @return the code
	 */
	public int getCode() {
		return code;
	}
	/**
	 * @param code the code to set
	 */
	public void setCode(int code) {
		this.code = code;
	}
	/**
	 * @return the msg
	 */
	public String getMsg() {
		return msg;
	}
	/**
	 * @param msg the msg to set
	 */
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	public int getTotalPage() {
		int num = count / limit;
		if(count % limit != 0) {
			num++;
		}
		return num;
	}

	@Override
	public String toString() {
		return "PageData [data=" + data + ", count=" + count + "]";
	}

	
}